package main

import (
	"encoding/json"
	"fmt"
)

func main() {
	p := Person{
		Name: "张三",
		Age:  18,
	}
	s, _ := json.Marshal(p)
	fmt.Println(string(s))

	str := `{"name":"张三","age":18}`
	fmt.Printf("%v \n", []byte(str))
	var p2 Person
	_ = json.Unmarshal([]byte(str), &p2)
	fmt.Printf("%#v", p2)
}

type Person struct {
	Name string `json:"name"`
	Age  int    `json:"age"`
}
